package com.sls.game.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.SevenNineNineSixAssistDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.snns.SevenNineNineSixRechargeAssistInfo;

@Repository("sevenNineNineSixAssistDAO")
public class SevenNineNineSixAssistDAOImpl extends
		SuperDAO<SevenNineNineSixRechargeAssistInfo> implements
		SevenNineNineSixAssistDAO {

	@Override
	public void insertAssistInfo(SevenNineNineSixRechargeAssistInfo assistInfo) {
		this.getSqlSession().insert(
				"mybatis.xml.SnnsRechargeAssistInfoMapper.insert", assistInfo);
	}

	/**
	 * 根据条件，查询记录（商品编号、&& 区域 && 服务器）
	 * 
	 * @param reAsInfo
	 * @return
	 */
	@Override
	public SevenNineNineSixRechargeAssistInfo queryByCondition(
			SevenNineNineSixRechargeAssistInfo reAsInfo) {
		SevenNineNineSixRechargeAssistInfo info = null;
		info = this.getSqlSession().selectOne(
				"mybatis.xml.SnnsRechargeAssistInfoMapper.queryByCondition",
				reAsInfo);

		return info;
	}

	/**
	 * 记录更新
	 * 
	 * @param assistInfo
	 * @date 2013-04-26
	 */
	@Override
	public void updateAssistInfo(SevenNineNineSixRechargeAssistInfo assistInfo) {
		this.getSqlSession().update(
				"mybatis.xml.SnnsRechargeAssistInfoMapper.updateAssistInfo",
				assistInfo);
	}

	/**
	 * 分页查询
	 * 
	 * @param query
	 * @return
	 * @date 2013-04-27
	 */
	@Override
	public Pagination<SevenNineNineSixRechargeAssistInfo> queryAuxiByPage(
			SevenNineNineSixRechargeAssistInfo query) {
		Pagination<SevenNineNineSixRechargeAssistInfo> paginationList = null;
		Integer rowCount = queryRowCount(query);
		query.calculate();
		List<SevenNineNineSixRechargeAssistInfo> list = queryAuxiInfoList(query);
		paginationList = this.queryPagination(rowCount, list, query);
		return paginationList;
	}

	/**
	 * 记录结果集
	 * 
	 * @param query
	 * @return
	 */
	private List<SevenNineNineSixRechargeAssistInfo> queryAuxiInfoList(
			SevenNineNineSixRechargeAssistInfo query) {

		List<SevenNineNineSixRechargeAssistInfo> list = this.getSqlSession()
				.selectList("mybatis.xml.SnnsProductMapper.queryAuxiInfoList",
						query);
		return list;
	}

	/**
	 * 查询符合条件的记录个数
	 * 
	 * @param query
	 * @return
	 */
	private int queryRowCount(SevenNineNineSixRechargeAssistInfo query) {
		int rowCount = this
				.getSqlSession()
				.selectOne(
						"mybatis.xml.SnnsRechargeAssistInfoMapper.queryRowCount",
						query);
		return rowCount;
	}

}
